﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Entities;
using Core;

namespace DAL
{
    public class HoaDonDAL
    {
        public static List<HoaDon> LayTatCa()
        {
            try
            {
                return CBO.FillCollection<HoaDon>(DataProvider.Instance.ExecuteReader("HoaDon_LayTatCa"));

            }
            catch
            {

                return new List<HoaDon>();
            }
        }
        public static bool Them(HoaDon hd)
        {
            try
            {
                object rs = DataProvider.Instance.ExecuteNonQueryWithOutput("@IDHoaDon", "HoaDon_Them", hd.IDHoaDon, hd.IDKhachHang, hd.NgayDatHang, hd.NgayNhanHang, hd.TrangThai, hd.TenNguoiNhan, hd.DCNguoiNhan, hd.GiaTien, hd.GhiChu);
                return Convert.ToInt32(rs) > 0;
            }
            catch
            {

                return false;
            }
        }
        public static bool Sua(HoaDon hd)
        {
            try
            {
                object rs = DataProvider.Instance.ExecuteNonQuery("HoaDon_Sua", hd.IDHoaDon, hd.IDKhachHang, hd.NgayDatHang, hd.NgayNhanHang, hd.TrangThai, hd.TenNguoiNhan, hd.DCNguoiNhan, hd.GiaTien, hd.GhiChu);
                return Convert.ToInt32(rs) > 0;
            }
            catch
            {

                return false;
            }
        }
        public static bool Xoa(string Id)
        {
            try
            {
                int rs = DataProvider.Instance.ExecuteNonQuery("HoaDon_Xoa", Convert.ToInt32(Id));
                return Convert.ToInt32(rs) > 0;
            }
            catch
            {

                return false;
            }
        }
    }
}
